#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
class Solution
{
public:
    int numUniqueEmails(vector<string> &emails)
    {
        unordered_set<string> emailSet;
        for (auto &email : emails)
        {
            string local;
            for (char c : email)
            {
                if (c == '+' || c == '@')
                {
                    break;
                }
                if (c != '.')
                {
                    local += c;
                }
            }
            emailSet.emplace(local + email.substr(email.find('@')));
        }
        return emailSet.size();
    }
};
int main()
{
    Solution s;
    vector<string> emails = {"test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com", "testemail+david@lee.tcode.com"};
    cout << s.numUniqueEmails(emails) << endl;
    system("pause");
    return 0;
}
